<template>
  <el-card shadow="never">
    <div slot="header">
      <el-button @click="$router.push({ name: 'assetsPlan' })">返回</el-button>
    </div>
    <el-tabs v-model="name">
      <el-tab-pane label="盘点计划" name="plan">
        <task-detail ref="taskDetail" />
      </el-tab-pane>
      <el-tab-pane label="盘点记录" name="record">
        <task-record ref="taskRecord" />
      </el-tab-pane>
    </el-tabs>
  </el-card>
</template>

<script>
import TaskDetail from './detail'
import TaskRecord from './record'
import { getSession, setSession, removeSession } from '@/utils/util'

export default {
  components: {
    TaskDetail,
    TaskRecord
  },
  data() {
    return {
      name: 'plan',
      mdl: {}
    }
  },
  mounted() {
    console.log('route', this.$route)
    const { params } = this.$route
    if (JSON.stringify(params) !== '{}') {
      this.mdl = Object.assign({}, params.obj)
      setSession('taskListDetail', this.mdl)
    } else {
      this.mdl = Object.assign({}, getSession('taskListDetail'))
    }
    this.$refs.taskRecord.edit(this.mdl)
    this.$refs.taskDetail.edit(this.mdl)
  },
  destroyed() {
    removeSession('taskListDetail')
  }
}
</script>

<style lang="less" scoped>
.link-wrapper {
  height: 43px;
  a {
    padding: 12px 16px;
    border: 1px solid #dcdcdc;
    border-right: none;
    color: #333333;
    &:last-child {
      border-right: 1px solid #dcdcdc;
    }
    &.router-link-exact-active {
      color: #1890ff;
    }
  }
}
</style>